package com.tencreat.service.mall.impl;

import java.time.LocalDateTime;
import java.util.List;

import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.domain.mall.MallMessageList;
import com.tencreat.mapper.mall.MallMessageListMapper;
import com.tencreat.domain.mall.vo.MallMessageListVO;
import com.tencreat.service.mall.IMallMessageListService;
import org.springframework.stereotype.Service;

/**
 * 消息列Service业务层处理
 *
 * @author tencreat
 * @date 2021-11-24
 */
@Service
public class MallMessageListServiceImpl extends ServiceImpl<MallMessageListMapper, MallMessageList> implements IMallMessageListService {


    /**
     * 查询消息列
     *
     * @param id 消息列ID
     * @return 消息列
     */
    @Override
    public MallMessageList selectMallMessageListById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    @Override
    public List<MallMessageListVO> selectList(Integer isToday,String mobile) {
        return baseMapper.list(isToday,mobile);
    }

    @Override
    public Long unreadMessageSum() {
        return baseMapper.unreadMessageSum();
    }

    @Override
    public List<MallMessageListVO> listByUserId(Long userId) {
        return baseMapper.listByUserId(userId);
    }

    /**
     * 新增消息列
     *
     * @param mallMessageList 消息列
     * @return 结果
     */
    @Override
    public int insertMallMessageList(MallMessageList mallMessageList) {
        mallMessageList.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(mallMessageList);
    }

    /**
     * 修改消息列
     *
     * @param mallMessageList 消息列
     * @return 结果
     */
    @Override
    public int updateMallMessageList(MallMessageList mallMessageList) {
        mallMessageList.setUpdateTime(LocalDateTime.now());
        return baseMapper.updateById(mallMessageList);
    }

    /**
     * 批量删除消息列
     *
     * @param ids 需要删除的消息列ID
     * @return 结果
     */
    @Override
    public int deleteMallMessageListByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除消息列信息
     *
     * @param id 消息列ID
     * @return 结果
     */
    @Override
    public int deleteMallMessageListById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }
}
